package com.kotlin.lib.coroutines

import kotlinx.coroutines.*

fun printlnInfo(content: String) {
    println("${Thread.currentThread().name} $content")
}

fun main() = runBlocking<Unit> {
    val threadLocal = ThreadLocal<String>()
    threadLocal.set("main")
    printlnInfo(" preLaunch  threadLocal:${threadLocal.get()}")
    launch(Dispatchers.Default + threadLocal.asContextElement("default")) {
        printlnInfo(" in Launch  threadLocal:${threadLocal.get()}")
        yield()
        printlnInfo(" in Launch after yield  threadLocal:${threadLocal.get()}")
    }

    printlnInfo(" afterLaunch threadLocal:${threadLocal.get()}")
}